package com.wxtf.platform.plugins.user;

import java.io.Serializable;
import java.util.*;

/**
 * <li>Title: UserBean.java</li>
 * <li>Project: baseplatform</li>
 * <li>Package: com.wxtf.platform.plugins.user</li>
 * <li>Description: 用户登录相关信息</li>
 * <li>Copyright: Copyright (c) 2012</li>
 * <li>Company: wxthtf Technologies </li>
 * <li>Created on Sep 14, 2012 3:52:23 PM</li>
 *
 * @author chun_chang
 * @version 1.0.0.0
 *
 */
public class UserBean implements Serializable{
	private static final long serialVersionUID = 1L;
	private String userId;// 用户ID
	private String userrelName;// 真实姓名
	private String dbType;// 数据库类型
	private String curOrgId;// 当前机构ID
	private String curOrgName;// 当前机构
	private String curSubOrgId;// 当前及以下机构ID串
	private String curSubOrgOptions;// 当前及以下机构的下拉框option
	private String userCss;// 用户登录样式
	private String userLay;// 用户布局
	private List<Map<String, String>> orgMap = new ArrayList<Map<String, String>>();// 用户机构列表 ids, department_id, caption, levels, child, child2
	private Map<String, String> globalMap = new HashMap<String, String>();// 系统参数
	private List<Map<String, Object>> quickIconList = new ArrayList<Map<String, Object>>();// 快捷图标列表
	private Map<String,List<Map<String, String>>> dicMap = new HashMap<String,List<Map<String, String>>>();// 字典集合

	
	/** 
	 * 描述：getCurSubOrgIds 根据机构获取当前机构及以下机构ID串
	 * @param curOrgId
	 * @return
	 * @CreateOn Sep 14, 2012  3:52:00 PM
	 * @author chun_chang
	 */
	public String getCurSubOrgIds(String curOrgId){
		String curSubOrgId = "";
		for(Map<String, String> map: this.getOrgMap()) {
			String ids = map.get("ids");
			if(ids.indexOf(curOrgId) > -1) {
				curSubOrgId += "'" + map.get("department_id") + "',";
			}
		}
		if(!"".equals(curSubOrgId)) {
			curSubOrgId = curSubOrgId.substring(0, curSubOrgId.length() - 1);
		}
		return curSubOrgId;
	}
	
	public String getSubOrgIds(String curOrgId){
		String curSubOrgId = "";
		String curOrgId1 = "_" + curOrgId;
		for(Map<String, String> map: this.getOrgMap()) {
			String ids = map.get("ids");
			if(ids.indexOf(curOrgId1) > -1) {
				curSubOrgId += "'" + map.get("department_id") + "',";
			}
		}
		if(!"".equals(curSubOrgId)) {
			curSubOrgId = curSubOrgId.replaceAll("'" + curOrgId + "'", "''").replaceAll("'',", "").replaceAll(",''","");
			curSubOrgId = curSubOrgId.substring(0, curSubOrgId.length() - 1);
		}
		return curSubOrgId;
	}
	
	public String getOrgPId(String orgId){
		String pid = "";
		for(Map<String, String> map: this.getOrgMap()) {
			String id = map.get("department_id");
			if(id.equals(orgId)) {
				String ids = map.get("ids");
				String[] temp = ids.split("_");
				pid = temp[temp.length - 2];
				break;
			}
		}
		return pid;
	}
	
	public String getOrgLevel(String orgId){
		String level = "";
		for(Map<String, String> map: this.getOrgMap()) {
			String id = map.get("department_id");
			if(id.equals(orgId)) {
				level = map.get("levels");
				break;
			}
		}
		return level;
	}
	
	
	
	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getUserrelName() {
		return userrelName;
	}

	public void setUserrelName(String userrelName) {
		this.userrelName = userrelName;
	}

	public String getUserCss() {
		return userCss;
	}

	public void setUserCss(String userCss) {
		this.userCss = userCss;
	}

	public Map<String, String> getGlobalMap() {
		return globalMap;
	}

	public void setGlobalMap(Map<String, String> globalMap) {
		this.globalMap = globalMap;
	}

	public String getDbType() {
		return dbType;
	}

	public void setDbType(String dbType) {
		this.dbType = dbType;
	}

	public String getUserLay() {
		return userLay;
	}

	public void setUserLay(String userLay) {
		this.userLay = userLay;
	}

	public List<Map<String, String>> getOrgMap() {
		List<Map<String, String>> list = new ArrayList<Map<String,String>>();
		for(Map<String, String> m: orgMap){
			Map<String, String> map = new HashMap<String,String>();
			map.put("ids", m.get("ids"));
			map.put("department_id", m.get("department_id"));
			map.put("caption", m.get("caption"));
			map.put("levels", m.get("levels"));
			map.put("child", m.get("child"));
			map.put("child2", m.get("child2"));
			list.add(map);
		}
		return list;
	}

	public void setOrgMap(List<Map<String, String>> orgMap) {
		this.orgMap = orgMap;
	}

	public List<Map<String, Object>> getQuickIconList() {
		return quickIconList;
	}

	public void setQuickIconList(List<Map<String, Object>> quickIconList) {
		this.quickIconList = quickIconList;
	}

	public String getCurOrgId() {
		return curOrgId;
	}

	public void setCurOrgId(String curOrgId) {
		this.curOrgId = curOrgId;
	}

	public String getCurOrgName() {
		return curOrgName;
		
	}
	public void setCurOrgName(String curOrgName) {
		this.curOrgName = curOrgName;
	}
	
	public List<Map<String, String>> getDicItemsByDicType(String dicType){
		return this.dicMap.get(dicType);
	}

	public void setDicMap(Map<String, List<Map<String, String>>> dicMap) {
		this.dicMap = dicMap;
	}

	public Map<String, List<Map<String, String>>> getDicMap() {
		return dicMap;
	}

	public String getCurSubOrgId() {
		return curSubOrgId;
	}

	public void setCurSubOrgId(String curSubOrgId) {
		this.curSubOrgId = curSubOrgId;
	}

	public String getCurSubOrgOptions() {
		return curSubOrgOptions;
	}

	public void setCurSubOrgOptions(String curSubOrgOptions) {
		this.curSubOrgOptions = curSubOrgOptions;
	}

	
}
